﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;
using NHibernate.Cfg;

namespace NhibernateSample.Data
{
	public class NhibernateHelper
	{
		private ISessionFactory _sessionFactory;

		public NhibernateHelper()
		{
			_sessionFactory = GetSessionFactory();
		}

		private ISessionFactory GetSessionFactory()
		{ 
			Configuration cfg = new Configuration();

			return cfg.Configure().BuildSessionFactory();
		}

		public ISession GetSession()
		{
			return _sessionFactory.OpenSession();
		}
	}
}
